﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StateDemo
{
    class Context
    {
        /// <summary>
        /// 定义出所有电梯状态
        /// </summary>
        public static OpeningState OpeningState = new OpeningState();
        public static ClosingState ClosingState = new ClosingState();
        public static RunningState RunningState = new RunningState();
        public static StoppingState StoppingState = new StoppingState();
        /// <summary>
        /// 定义一个当前电梯状态
        /// </summary>
        private ILiftState _liftState;
        public ILiftState LiftState
        {
            get
            {
                return this._liftState;
            }
            set
            {
                this._liftState = value;
                //把当前的环境通知到各个实现类中
                this._liftState.Context = this;
            }
        }

        public void Open()
        {
            this._liftState.Open();
        }

        public void Close()
        {
            this._liftState.Close();
        }

    }
}
